<template>
  <view class="v-timeline">
    <view
      v-for="(item, index) in list"
      :key="index"
      class="v-timeline-item"
    >
      <view class="left-part">
        <view class="dot">
          <view class="inner" />
        </view>
        <view class="line" />
      </view>
      <view class="right-part">
        <view class="header">
          <view class="title">
            {{ item.title }}
          </view>
          <view class="sub">
            {{ item.sub }}
          </view>
        </view>
        <view class="content">
          {{ item.content }}
        </view>
      </view>
    </view>
  </view>
</template>

<script setup lang="ts">
defineProps<{
  list: {
    title: string;
    sub?: string;
    content?: string;
  }[];
}>();
</script>

<style lang="scss" scoped>
.v-timeline {
  .v-timeline-item {
    display: flex;
    align-items: stretch;
    gap: 30rpx;
    .left-part {
      display: flex;
      flex-direction: column;
      align-items: center;
      .dot {
        height: 36rpx;
        width: 36rpx;
        border-radius: 50%;
        background-color: transparent;
        display: flex;
        align-items: center;
        justify-content: center;
        .inner {
          height: 16rpx;
          width: 16rpx;
          border-radius: 50%;
          background-color: #cccccc;
        }
      }
      .line {
        flex: 1;
        min-height: 0;
        width: 1px;
        border-right: 1px dashed #cccccc;
      }
    }
    .right-part {
      .header {
        display: flex;
        align-items: baseline;
        gap: 14rpx;
        opacity: 0.9;
        margin-bottom: 8rpx;
        .title {
          color: #333333;
          font-weight: bold;
          font-size: 26rpx;
          flex: 1;
          min-width: 0;
          overflow: hidden;
          white-space: nowrap;
          text-overflow: ellipsis;
          word-break: break-all;
        }
        .sub {
          color: #999999;
          font-size: 24rpx;
        }
      }
      .content {
        color: #999999;
        font-size: 24rpx;
        line-height: 34rpx;
        margin-bottom: 50rpx;
      }
    }
    &:first-child {
      .left-part {
        .dot {
          background-color: rgba(255, 47, 59, 0.102);
          .inner {
            background-color: #ff2f3b;
          }
        }
        .line {
          border-top: none;
        }
      }
      .right-part {
        opacity: 1;
      }
    }
    &:last-child {
      .left-part .line {
        display: none;
      }
    }
  }
}
</style>
